package com.devops.admin.graphql;

import com.devops.admin.model.TableResult;
import com.devops.admin.po.DOSK8sIngressPo;
import com.devops.admin.service.DOSK8sIngressService;
import com.devops.admin.vo.*;
import com.devops.common.annotation.DOSLog;
import com.devops.constant.DevOpsConstant;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.InputArgument;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @ClassName DOSK8sIngressDataFetcher
 * @Description ingress
 * @Author heyabo
 * @Date 2022/9/28 09:25
 * @Version 1.0
 **/
@DgsComponent
public class DOSK8sIngressDataFetcher {

    @Autowired
    private DOSK8sIngressService dosk8sIngressService;

    /**
     * @Author heyabo
     * @Description 通过用户身份查询ingress
     * @Date 14:04 2022/9/27
     * @Param []
     * @return com.devops.admin.model.TableResult<com.devops.admin.po.DOSClusterPo>
     **/
    @DgsQuery
    @DOSLog(description = "通过用户身份查询ingress")
    @RequiresPermissions(DevOpsConstant.RoleCode.LOGIN_USER)
    public TableResult<DOSK8sIngressPo> getIngressByUser(DOSK8sIngressVo ingressVo, DOSPageVo pageVo){

        return dosk8sIngressService.getIngressByUser(ingressVo,pageVo);
    }

    /**
     * @Author heyabo
     * @Description 查询集群下的ingress
     * @Date 13:46 2022/8/22
     * @Param [cluster]
     * @return java.util.List<com.devops.admin.po.DOSClusterPo>
     **/
    @DgsQuery
    @DOSLog(description = "查询集群下的ingress")
    @RequiresPermissions(value = {DevOpsConstant.RoleCode.SUPER_ADMINISTRATOR,DevOpsConstant.RoleCode.ADMINISTRATOR,
            DevOpsConstant.RoleCode.QA_ADMINISTRATOR},logical = Logical.OR)
    public TableResult<DOSK8sIngressPo> getIngress(@InputArgument DOSClusterVo clusterVo, DOSPageVo pageVo){

        return dosk8sIngressService.getIngress(clusterVo,pageVo);
    }

    /**
     * @Author heyabo
     * @Description 查询release的ingress
     * @Date 10:37 2022/9/28
     * @Param [ingress]
     * @return com.devops.admin.po.DOSK8sInressPo
     **/
//    @DgsQuery
//    @DOSLog(description = "查询release的ingress")
//    @RequiresPermissions(DevOpsConstant.RoleCode.LOGIN_USER)
//    public List<DOSK8sInressPo> getReleaseIngress(@InputArgument DOSK8sReleaseVo releaseVo) throws IOException {
//        DOSNamespaceChart dosNamespaceChart = releaseService.dealDbRelease(releaseVo);
//        return dosk8sIngressService.getReleaseIngress(dosNamespaceChart);
//    }
}
